package com.yunkeji.common.enums.app;

import com.yunkeji.common.exception.AppServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/** 真人认证/实名认证状态 */
@Getter
@AllArgsConstructor
public enum CheckStatus {
    未提交(0),
    待审核(1),
    审核通过(2),
    审核拒绝(3);
    private Integer code;

    public static CheckStatus getByCode(Integer code) {
        CheckStatus[] values = CheckStatus.values();
        Optional<CheckStatus> first =
                Arrays.stream(values).filter(item -> item.getCode().equals(code)).findFirst();
        if (first.isPresent()) {
            return first.get();
        } else {
            throw AppServiceException.paramException("审核状态参数异常");
        }
    }
}
